<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/


namespace Help\Controller;
use Think\Controller;
class IndexController extends Controller {
	
	//列表
	public function indexAction(){
		
		$model=new \News\Model\ArticleModel();
		$result=$model->GetList(2);
		
		$this->assign('list',$result['list']);	
		$this->assign('page',$result['page']);
		$this->assign('route',$result['route']);
		$this->assign('name',$result['name']);
		
		$this->GetCategory();
		
		$this->assign('PATH',array('帮助',$result['name']));
		$this->assign('SEO',array('title'=>'帮助'.$result['name'],'keywords'=>'帮助','description'=>'帮助'));
		
		$this->display();
	}
	
	public function GetCategory(){
		$categoryarr=M('Category')->token(false)->where(" help=1 ")->select();
		$this->assign('categoryarr',$categoryarr);
	}
	
	//显示
	public function showAction(){
		$id=intval($_GET['id']);
		$article= M('Article')->token(false)->where(" id=$id ")->find();
		
		if(empty($article['id'])){
			$this->error('对不起，数据不存在！','/',3);
		}
		
		M('Article')->token(false)->where(" id=$id ")->setInc('show_number');
		
		$this->assign('article',$article);
		
		$uparticle=M('Article')->token(false)->where(" id<$id AND type=2 ")->find();
        $nextarticle=M('Article')->token(false)->where(" id>$id AND type=1 ")->find();
		
		$this->assign('uparticle',$uparticle);
		$this->assign('nextarticle',$nextarticle);
		
		$this->GetCategory();
		
		$this->assign('PATH',array('帮助',$article['subject']));
		$this->assign('SEO',array('title'=>$article['subject'],'keywords'=>$article['subject'],'description'=>$article['subject']));
		
		$this->display();
	}
}